package com.cykj.controller;

import com.cykj.service.CombinationService;
import com.cykj.util.ResponseDto;
import com.cykj.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/combination")
@RestController
public class CombinationController {
    @Autowired
    private CombinationService combinationService;
    @RequestMapping("/getAllCombination")
    public ResponseDto getAllCombination(@RequestBody PageVo vo){
        return combinationService.getAllCombination(vo.getPageCurr(), vo.getPageSize());
    }
    @RequestMapping("/changeStatus")
    public ResponseDto changeStatus(int proStatus,int combinationId){
        if (proStatus == 2){
            proStatus = 0;
        }else if (proStatus == 1){
            proStatus =1;
        }
        return combinationService.changeStatus(proStatus, combinationId);
    }
    @RequestMapping("/deleteRow")
    public ResponseDto deleteRow(int combinationId){
        return combinationService.deleteRow(combinationId);
    }
    @RequestMapping("/lookInclude")
    public ResponseDto lookInclude(int id){
        return combinationService.lookInclude(id);
    }
    @RequestMapping("/getProjectName")
    public ResponseDto getProjectName(int id){
        return combinationService.getProjectName(id);
    }
    @RequestMapping("/alterInfo")
    public ResponseDto alterInfo(int combinationId, String combinationName, String combinationPrice, String projectName){
        return combinationService.alterInfo(combinationId, combinationName, combinationPrice, projectName);
    }
    @RequestMapping("/searchInfo")
    public ResponseDto searchInfo(String value, int pageCurr, int pageSize) {
        return combinationService.searchInfo(value, pageCurr, pageSize);
    }
    @RequestMapping("/getAllName")
    public ResponseDto getAllName(){
        return combinationService.getAllName();
    }
    @RequestMapping("/commitDelete")
    public ResponseDto commitDelete(String checked) {
        try {
            return combinationService.commitDelete(checked);
        } catch (Exception e) {
            return new ResponseDto(-1, "操作失败了", null);
        }
    }
    @RequestMapping("/addCommit")
    public ResponseDto addCommit(String name, String price,String includePro, String status){
        return combinationService.addCommit(name, price, includePro, status);
    }
    @RequestMapping("/borderPriceSearch")
    public ResponseDto borderPriceSearch(int minPrice,int maxPrice,int pageCurr, int pageSize){
        return combinationService.borderPriceSearch(minPrice, maxPrice,pageCurr,pageSize);
    }
}
